class Solution:
    
    def indexLetter(self, s: str) -> int:
        if s == 'a':
            return 0
        if s == 'e':
            return 1
        if s == 'i':
            return 2
        if s == 'o':
            return 3
        if s == 'u':
            return 4
        return -1

    def findTheLongestSubstring(self, s: str) -> int:
        # print 
        #f = [[0,0,0,0,0] for i in range(len(s))]
        f = [0,0,0,0,0]
        c = -1
        dt = {0:0}
        result = 0
        preStatus = 0
        for i in s:
            c += 1
            idx = self.indexLetter(i)
            if idx != -1:
                f[idx] = (f[idx] + 1) % 2
                preStatus = k = self.toInt(f)
                if  not k in dt:
                    dt[k] = c
            val = c - dt[preStatus]
            if preStatus == 0:
                val += 1
            result = max(result, val)
        return result

    def toInt(slef, arr) -> int:
        sum = 0
        c = 0
        for i in arr:
            sum += (i << c)
            c = c + 1
        #print("arr = ",arr," sum = ",sum)    
        return sum        
sol = Solution()
cases = ("eleetminicoworoep","leetcodeisgreat","bcbcbc","amntyyaw","eleetminicoworoep")
#cases =  ("amntyyaw","")
for c in cases:
    print("case: ", c , "result=",sol.findTheLongestSubstring(c))
